import random

def BubbleSort(elementsList):
    for j in range(len(elementsList)-1):
        for i in range(len(elementsList)-1-j):           
            if elementsList[i] > elementsList[i+1]:
                temp = elementsList[i]
                elementsList[i] = elementsList[i+1]
                elementsList[i+1] = temp
if __name__ == "__main__":
    alist = list(range(20))
    random.shuffle(alist)#生成大于等于0，且小于20的随机list
    print("排序前的list")
    print(alist)
    BubbleSort(alist)
    print("排序后的list")
    print(alist)
